<?php
$this->extend('/Common/admin_index');

$this->Html
        ->addCrumb('', '/admin', array('icon' => 'home'))
        ->addCrumb(__('Countries'), array('action' => 'index'))
        ->addCrumb(__('Areas'), $this->here);

echo $this->Form->create('Areas', array('url' => array('controller' => 'areas', 'action' => 'process')), array('class' => 'form-inline')
);
?>
<table class="table table-striped">
<?php
$list_header = array();
$list_header[] = '';
$list_header[] = $this->Paginator->sort('id');
$list_header[] = $this->Paginator->sort('name');
$list_header[] = $this->Paginator->sort('alias');
$list_header[] = $this->Paginator->sort('city_count');
$list_header[] = $this->Paginator->sort('status');
$list_header[] = __('Actions');

$tableHeaders = $this->Html->tableHeaders($list_header);
?>
        <thead>
        <?php echo $tableHeaders; ?>
        </thead>
                <?php
                $rows = array();
                $i = 0;
                foreach ($areas as $area) {
                        $actions = array();
                        $actions[] = $this->Croogo->adminRowAction('', array('controller' => 'areas', 'action' => 'moveup', $area['Area']['id']), array('icon' => 'arrow-up', 'tooltip' => __('Move up'),
                                ));
                        $actions[] = $this->Croogo->adminRowAction('', array('controller' => 'areas', 'action' => 'movedown', $area['Area']['id']), array('icon' => 'arrow-down', 'tooltip' => __('Move down'),
                                )
                        );
                        $actions[] = $this->Croogo->adminRowActions($area['Area']['id']);
                        $actions[] = $this->Croogo->adminRowAction('', array('controller' => 'areas', 'action' => 'edit', $area['Area']['id']), array('icon' => 'pencil', 'tooltip' => __('Edit this item'))
                        );
                        $actions[] = $this->Croogo->adminRowAction('', '#Area' . $area['Area']['id'] . 'Id', array('icon' => 'trash', 'tooltip' => __('Remove this item'), 'rowAction' => 'delete'), __('Are you sure?')
                        );

                        $actions = $this->Html->div('item-actions', implode(' ', $actions));

                        $rows[$i][] = $this->Form->checkbox('Area.' . $area['Area']['id'] . '.id');
                        $rows[$i][] = $area['Area']['id'];
                        $rows[$i][] = $this->Html->link($area['Area']['name'], array('controller' => 'areas', 'action' => 'edit', $area['Area']['id']));
                        $rows[$i][] = $area['Area']['alias'];
                        $rows[$i][] = $area['Area']['city_count'];
                        $rows[$i][] = $this->element('admin/toggle', array(
                            'id' => $area['Area']['id'],
                            'status' => $area['Area']['status'],
                                ));
                        $rows[$i][] = $actions;
                        $i++;
                }

                echo $this->Html->tableCells($rows);
                ?>
</table>
<div class="row-fluid">
        <div id="bulk-action" class="control-group">
        <?php
        echo $this->Form->input('Area.action', array(
            'label' => false,
            'div' => 'input inline',
            'options' => array(
                'publish' => __('Publish'),
                'unpublish' => __('Unpublish'),
                'delete' => __('Delete'),
            ),
            'empty' => true,
        ));
        ?>
                <div class="controls">
                <?php echo $this->Form->end(__('Submit')); ?>
                </div>
        </div>
</div>